using System;
using System.Collections.Generic;
using System.Web.Http;
using Medora.Model.Institutions;
using Medora.Services;
using Medora.Services.Institutions;

namespace Medora.Web.App_Code
{
    public class ProvidersController : ControllerBase<Provider, ProviderFilter>
    {
        public ProvidersController(IProvidersService service)
            : base(service)
        {
        }

        [ActionName("GetByDepartment")]
        public IEnumerable<Provider> GetByDepartment(Guid departmentId)
        {
            var user = System.Web.Security.Membership.GetUser(User.Identity.Name);
            if (user != null && user.ProviderUserKey != null)
            {
                return _service.Get(new ProviderFilter { DepartmentId = departmentId });
            }
            return null;
        }
    }
}